
import { fromJS } from 'immutable';



const initialState = fromJS({
    count:1,
    userInfo:null,  //用户信息
    goodList:[],  //商品列表
    goodType:[],  //商品类型
    myLikes:[], //我的点赞列表
    myCollects:[], //我的收藏列表
    myCart:[] , //存放全局的我的购物车
})

export const data = (state=initialState,action )=>{
    const {type,payload} = action;
    console.log(action) 


    switch(type){
        case "getGoodTypeAsync":
            return state.set('goodType',payload)
            break;

        case "getGoodListAsync":
            return state.set('goodList',payload)
            break;

        case "getuserInfoAsync":
            return state.set('userInfo',payload)
            break;

            // 点赞列表
        case "getMyLikes":
            return state.set('myLikes',payload)
            break;
    

            // 收藏列表
        case "getMyCollects":
            return state.set('myCollects',payload)
            break;

            // 评论
            case "getMyComments":
                return state.set("myComments",payload)
                break;
            
            // 购物车
        case "getMyCart":
            return state.set('myCart',payload)
            break;
           
            
        default:
            console.log(state)
            return state;
            break;
    }
}
